{% extends base_template %}

{% load seahub_tags avatar_tags i18n %}
{% load url from future %}

{% block extra_style %}
<style type="text/css">
#main-panel { position:relative; }
.go-back { top:-4px; }
</style>
{% endblock %}

{% block main_panel %}
    <a class="go-back" title="{% trans "Back to Library" %}" href="{% url 'repo' repo.id %}"><span class="icon-chevron-left"></span></a>
    <div class="w100 ovhd">
        <h2 class="fleft">{{repo.props.name}} {% trans "'s trash" %}</h2>
        {% if enable_clean %}
        <button id="online-gc" class="fright">{% trans "Clean" %}</button>
        {% endif %}
    </div>

    <div class="repo-file-list-outer-container">
        <div class="repo-file-list-inner-container">
            <div class="repo-file-list-topbar">
                <span class="path">
                {% trans "Current path: " %}
		<a href="?days={{days}}">{{repo.props.name}} {% trans "'s trash" %}</a>
		{% if not show_recycle_root %}
                    {% for name, link in zipped %}
                        {% if not forloop.last %}
                        / <a href="?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ link|urlencode }}&days={{days}}">{{ name }}</a>
                        {% else %}
                        / {{ name }}
                        {% endif %}
                    {% endfor %}
		{% endif %}
                </span>

		{% if show_recycle_root %}
		<span class="fright">
		    {% if days != 7 %}
		    <a href="?days=7">{% trans "a week" %}</a> /
		    {% else %}
		    {% trans "a week" %} /
		    {% endif %}
		    {% if days != 30 %}
		    <a href="?days=30">{% trans "a month" %}</a> /
		    {% else %}
		    {% trans "a month" %} /
		    {% endif %}
		    {% if days != 0 %}
		    <a href="?days=0">{% trans "all" %}</a>
		    {% else %}
		    {% trans "all" %}
		    {% endif %}
		</span>
		{% endif %}
            </div>
            <!-- /.repo-file-list-topbar -->
            <table class="repo-file-list">
                <tr>
                    <th width="5%"></th>
                    <th width="60%">{% trans "Name" %}</th>
                    <th width="15%">{% trans "Delete Time" %}</th>
                    <th width="10%">{% trans "Size" %}</th>
                    <th width="10%">{% trans "Operations" %}</th>
                </tr>

                {% for dirent in dir_list %}
                <tr>
                    <td class="alc"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory" %}" /></td>
                    {% if show_recycle_root %}
                    <td><a href="?commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.obj_name }}</a></td>
                    <td>{{ dirent.delete_time|translate_seahub_time }}</td>
                    <td></td>
                    <td><a class="op vh" href="{% url 'repo_revert_dir' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}&from=recycle">{% trans "Restore" %}</a></td>
                    {% else %}
                    <td><a href="?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.obj_name }}</a></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    {% endif %}
                </tr>
                {% endfor %}

                {% for dirent in file_list %}
                <tr>
                    <td class="alc"><img src="{{ MEDIA_URL }}img/file/{{ dirent.obj_name|file_icon_filter }}" alt="{% trans "File" %}" /></td>
                    {% if show_recycle_root %}
                    <td><a class="normal" href="{% url 'view_trash_file' repo.id %}?obj_id={{ dirent.obj_id }}&commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.obj_name }}</a></td>
                    <td>{{ dirent.delete_time|translate_seahub_time }}</td>
                    <td>{{ dirent.file_size|filesizeformat }}</td>
                    <td><a class="op vh" href="{% url 'repo_revert_file' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}&from=recycle">{% trans "Restore" %}</a></td>
                    {% else %}
                    <td><a class="normal" href="{% url 'view_trash_file' repo.id %}?obj_id={{ dirent.obj_id }}&commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}&days={{days}}">{{ dirent.props.obj_name }}</a></td>
                    <td></td>
                    <td>{{ dirent.file_size|filesizeformat }}</td>
                    <td></td>
                    {% endif %}
                </tr>
                {% endfor %}
            </table>
        </div>
    </div>

    {% if enable_clean %}
    <form id="gc-form" class="hide" method="post" action="{% url "repo_online_gc" repo.id %}">{% csrf_token %}
        <h3>{% trans "Clean" %}</h3>
        <p>{% trans "Clear files in trash and history：" %}</p>
        <select name="day" class="w100" style="margin-bottom:5px;">
            <option value="3">{% trans "3 days ago" %}</option>
            <option value="7">{% trans "1 week ago" %}</option>
            <option value="30">{% trans "1 month ago" %}</option>
            <option value="0">{% trans "all" %}</option>
        </select>
        <button type="submit" class="submit">{% trans "Submit" %}</button>
        <button type="button" class="simplemodal-close">{% trans "Cancel" %}</button>
    </form>
    {% endif %}
    {% endblock %}

{% block extra_script %}
<script type="text/javascript">
$('#main-panel').removeClass('ovhd');

{% if enable_clean %}
$('#online-gc').click(function() {
    $('#gc-form').modal({focus:false});
    $("#simplemodal-container").css({'height':'auto'});
});
{% endif %}
</script>
{% endblock %}
